<docs>
## 已收藏页面
</docs>
<template>
  <div class="con-layout collected noPadBottom">
    <my-bread title="已收藏" :goback="true" ref="head"></my-bread>
    <div class="content">
      <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
        <resume-list
          v-for="(item,index) in list"
          :key="index"
          :visibleSlide="visibleSlide"
          slideText="取消收藏"
          :data="item"
          :showYs="false"
          @link="link_bank"
          @slideFn="slideFn"
        ></resume-list>
      </van-list>
    </div>
  </div>
</template>

<script>
import resumeList from "base/job/jobList";
export default {
  components: { resumeList },
  data() {
    return {
      visibleSlide: true,
      pageNum: 1,
      pageSize: 10,
      list: [],
      loading: false,
      finished: false
    };
  },
  methods: {
    link_bank(item) {
      this.$loading = true;
      this.$http({
        url: "/dwgl/jlckBc",
        method: "post",
        data: {
          dwdjid: item.dwdjid,
          jlid: item.jlid,
          jlly: item.jlly,
          tdjlid: item.tdjlid,
          ckjlid: item.ckjlid
        }
      }).finally(()=>{
        this.$loading = false;
      }).then(res => {
        let _res = res.returnData;
        if (+_res.executeResult == 1) {
          this.$router.push({
            path: "/resume/resumeDetail",
            query: {
              jlid: item.jlid,
              tdjlid: item.tdjlid,
              fmstzly:3,
              jlly: item.jlly
            }
          });
        } else {
          this.alert({
            message: _res.message
          });
        }
      });
    },
    // 取消收藏事件
    slideFn(item) {
      this.$loading = true;
      this.$http({
        url: "/dwgl/jlscBc",
        method: "post",
        data: {
          jlid: item.jlid,
          dwdjid: item.dwdjid,
          ywcz: 3,
          jlly:item.jlly
        }
      })
        .finally(() => {
          this.$loading = false;
        })
        .then(res => {
          let _res = res.returnData;
          if (+_res.executeResult == 1) {
            this.list = [];
            this.pageNum = 1;
            this.onLoad();
          } else {
            this.$alert({
              message: _res.message,
              cb: () => {
                this.list = [];
                this.pageNum = 1;
                this.onLoad();
              }
            });
          }
        });
    },
    onLoad() {
      this.$http({
        url: "/msgl/yscck",
        method: "get",
        params: {
          pageNum: this.pageNum,
          pageSize: this.pageSize
        }
      }).then(res => {
        // 加载状态结束
        this.loading = false;
        this.finished = false;
        let data = res.returnData;
        if (+data.executeResult == 1) {
          this.pageNum++;
          this.list.push(...data.gwxxCx);
          if (this.pageNum > res.pageCount) {
            // 数据加载完毕
            this.finished = true;
          }
        } else {
          this.sildeShow = false;
          this.finished = true;
          return false;
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.collected {
  .content {
    padding: 20px 0;
  }
}
</style>
